import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/signUp', component: () => import('@/views/upload/sign-up'), hidden: true},
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/auth', component: () => import('@/views/upload/authJump'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/upload/home',
    name: '脑电上传系统',
    hidden: true,
    children: [{
      path: 'brain/home',
      component: () => import('@/views/upload/home'),
    }]
  },
  {
    path:'/upload',
    component:Layout,
    redirect:'/upload/home',
    name:'脑电管理系统',
    meta:{ title: '脑电管理系统', icon: 'example' },
    children: [
      {
        path: 'home',
        name: '首页',
        component: () => import('@/views/upload/home'),
        meta: { title: '首页', icon: 'table' }
      },
      {
        path:'research-list',
        name: '课题列表',
        component: () => import('@/views/upload/research-list'),
        meta:{ title: '课题列表',icon: 'table',keepAlive : true }
      },
      {
        path:'research-manager',
        name:'课题管理',
        hidden: true,
        component: () => import('@/views/upload/research-manager'),
        meta:{ title: '课题管理',icon: 'table'}
      },
      {
        path:'task',
        name:'任务管理',
        hidden: true,
        component: () => import('@/views/upload/task'),
        meta:{ title: '任务管理',icon: 'table'}
      },
      {
        path:'subject-manager',
        name:'被试管理',
        hidden: true,
        component: () => import('@/views/upload/subject-manager'),
        meta:{ title: '被试管理',icon: 'table'}
      },
      {
        path:'upload',
        name:'数据上传',
        hidden: true,
        component: () => import('@/views/upload/upload'),
        meta:{ title: '数据上传',icon: 'table'}
      },
      {
        path:'device',
        name:'设备管理',
        hidden: true,
        //hidden: this.$store.getters.roles==1,
        component: () => import('@/views/upload/device'),
        meta:{ title: '设备管理',icon: 'table'}
      },
      {
        path:'file-list',
        name:'文件列表',
        hidden: true,
        component: () => import('@/views/upload/file-list'),
        meta:{ title: '文件列表',icon: 'table'}
      },
      {
        path:'research-admin',
        name:'平台管理',
        hidden: true,
        component: () => import('@/views/upload/research-admin'),
        meta:{ title: '平台管理',icon: 'table'}
        // roles: ['admin', 'editor']
      },
      {
        path:'site-admin',
        name:'中心管理',
        hidden: true,
        component: () => import('@/views/upload/site-admin'),
        meta:{ title: '中心管理',icon: 'table'}
        // roles: ['admin', 'editor']
      },
      {
        path:'user-admin',
        name:'账户管理',
        hidden: true,
        component: () => import('@/views/upload/user-admin'),
        meta:{ title: '账户管理',icon: 'table'}
        // roles: ['admin', 'editor']
      },
      {
        path:'userInfo',
        name:'用户信息',
        component: () => import('@/views/upload/userInfo'),
        hidden: true,
        meta:{ title: '用户信息',icon: 'table'}
      },
      {
        path:'eeg',
        name:'波形可视化',
        component: () => import('@/views/upload/eeg'),
        hidden: true,
        meta:{ title: '波形可视化',icon: 'table'}
      }
    ]

  },
  { path: '*', redirect: '/404', hidden: true }
]


export const constantRouterMap2 = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/signUp', component: () => import('@/views/upload/sign-up'), hidden: true},
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/auth',
    component: () => import('@/views/upload/authJump'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/upload/home',
    name: '脑电上传系统',
    hidden: true,
    children: [{
      path: 'brain/home',
      component: () => import('@/views/upload/home'),
    }]
  },
  {
    path:'/upload',
    component:Layout,
    redirect:'/upload/home',
    name:'脑电管理系统',
    meta:{ title: '脑电管理系统', icon: 'example' },
    children: [
      {
        path: 'home',
        name: '首页',
        component: () => import('@/views/upload/home'),
        meta: { title: '首页', icon: 'table' }
      },
      {
        path:'research-list',
        name: '课题列表',
        component: () => import('@/views/upload/research-list'),
        meta:{ title: '课题列表',icon: 'table',keepAlive : true }
      },
      {
        path:'research-manager',
        name:'课题管理',
        hidden: true,
        component: () => import('@/views/upload/research-manager'),
        meta:{ title: '课题管理',icon: 'table'}
      },
      {
        path:'task',
        name:'任务管理',
        hidden: true,
        component: () => import('@/views/upload/task'),
        meta:{ title: '任务管理',icon: 'table'}
      },
      {
        path:'subject-manager',
        name:'被试管理',
        hidden: true,
        component: () => import('@/views/upload/subject-manager'),
        meta:{ title: '被试管理',icon: 'table'}
      },
      {
        path:'upload',
        name:'数据上传',
        hidden: true,
        component: () => import('@/views/upload/upload'),
        meta:{ title: '数据上传',icon: 'table'}
      },
      {
        path:'device',
        name:'设备管理',
        hidden: true,
        //hidden: this.$store.getters.roles==1,
        component: () => import('@/views/upload/device'),
        meta:{ title: '设备管理',icon: 'table'}
      },
      {
        path:'file-list',
        name:'文件列表',
        hidden: true,
        component: () => import('@/views/upload/file-list'),
        meta:{ title: '文件列表',icon: 'table'}
      },
      {
        path:'research-admin',
        name:'平台管理',
        //hidden: true,
        component: () => import('@/views/upload/research-admin'),
        meta:{ title: '平台管理',icon: 'table'}
        // roles: ['admin', 'editor']
      },
      {
        path:'site-admin',
        name:'中心管理',
        hidden: true,
        component: () => import('@/views/upload/site-admin'),
        meta:{ title: '中心管理',icon: 'table'}
        // roles: ['admin', 'editor']
      },
      {
        path:'user-admin',
        name:'账户管理',
        hidden: true,
        component: () => import('@/views/upload/user-admin'),
        meta:{ title: '账户管理',icon: 'table'}
        // roles: ['admin', 'editor']
      },
      {
        path:'userInfo',
        name:'用户信息',
        component: () => import('@/views/upload/userInfo'),
        hidden: true,
        meta:{ title: '用户信息',icon: 'table'}
      },
      {
        path:'eeg',
        name:'波形可视化',
        component: () => import('@/views/upload/eeg'),
        hidden: true,
        meta:{ title: '波形可视化',icon: 'table'}
      }
    ]

  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  mode:'history',
  routes: constantRouterMap,
  routes2: constantRouterMap2
})
